// 商品接口
import request from '../axios';

/**
 * 获取商品详情
 * @param {String} id 商品id
 */
export const findGoods = (id) => {
  return request({
    url: '/goods',
    method: 'get',
    data: {
      id: id,
    },
  });
};

/**
 * 获取猜你喜欢商品数据
 * @param {String} id  商品id
 * @param {Integer} limit 商品数量
 * @returns
 */
export const findRelevantGoods = ({ id, limit = 16 }) => {
  return request({
    url: '/goods/relevant',
    method: 'get',
    data: {
      id: id,
      limit: limit,
    },
  });
};

/**
 * 获取热销榜数据
 * @param {Integer} id 商品Id
 * @param {Integer} limit 获取数量
 * @param {Integer} type 热榜类型
 * @returns
 */
export const findHotGoods = ({ id, limit = 4, type = 1 }) => {
  return request({
    url: '/goods/hot',
    method: 'get',
    data: {
      id: id,
      limit: limit,
      type: type,
    },
  });
};

export const findComment = (id) => {
  return request({
    url: `/goods/${id}/evaluate`,
    method: 'get',
    mock: true,
  });
};

/**
 * 查询商品评价列表
 * @param {Integer} id 商品Id
 * @param {Object} params 筛选参数
 * @returns
 */
export const findGoodsCommentList = (id, params) => {
  return request({
    url: `/goods/${id}/evaluate/page`,
    method: 'get',
    data: {
      params,
    },
    mock: true,
  });
};
